package com.maxjay.component.metadata.core.command.processor;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.maxjay.component.metadata.core.command.EntityCommand;
import com.maxjay.system.service.BaseServiceJdbc;

@Service("entityCommandProcessor")
public class JdbcEntityCommandProcessor extends BaseServiceJdbc implements EntityCommandProcessor {

	@Override
	@Transactional
	public void executeCommand(EntityCommand entityCommand) {
		entityCommand.execute();
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void executeCommands(List<EntityCommand> entityCommands) {
		for (EntityCommand entityCommand : entityCommands) {
			entityCommand.execute();
		}
	}

}